Asterisk configuration for voicebot

CONFIGURATION
- the PJSIP subsystem is used (there are two possibilities - chan_sip and pjsip)
- the pjsip.conf describes:
   - endpoints - devices that can be connected to Asterisk or devices that Asterisk can connect to,
     in our case:
       a) twilio_inbound - endpoint where the SIP traffic from Twilio is coming to
       b) twilio_outbound - endpoint used to send SIP traffic to Twilio
       c) sip-connector - endpoint where the sip-connector from voicebot will connect too 
          (a bridge between Asterisk and voicebot backend)
       d) softphone - endpoint where a softphone can be connected for some testing purposes 
          (for example, linphone installed on the same machine)
       e) webrtc - endpoint where a web browser client can connect (certification authority and 
          server certificates are needed)
   - authorization - usually user name and password
   - access information (aors) - server URI and user name for the outbound connection, max number of connections for inbound
   - registration - information on how to register to Twilio as a SIP endpoint
   - traffic identification - the inbound SIP traffic is identified using the uri. Any traffic from other servers is ignored
   - transport layers - in our case UDP or WebSockets (!WebSockets need certificates)
- the extensions.conf describes routing between different endpoints:
   - the endpoints have "context". This means where the call came from. This is used in the extension.conf file as 
     a section. Then there is a regular expression for the called number, and a command to run, usually Dial(...)
- it is good to disable the chan_sip subsystem in modules.conf
   - add "noload => chan_sip.so" to the [modules] session
- use the configs/pjsip.conf, configs/extensions.conf and configs/modules.conf files as examples
- when the configuration is done, you should restart asterisk using
  systemctl restart asterisk


USEFUL COMMANDS

# connect to asterisk using remote console
# -vvvvv means set verbosity to 5
# -ddddd means set debug to 5
asterisk -rvvvvvddddd

# restart/start/stop the service
systemctl {restart/start/stop} asterisk

# see the log
journalctl -u asterisk

# restart asterisk core - may be done insteat restarting the whole service after a config file modification
> core restart now

# start/stop logging of sip messages
> pjsip set history on/off

# show sip messages
> pjsip show history

# other SIP related logging messages
> pjsip set logger on

# more verbosity/debug info, the same as asterisk "d" and "v" command-line options
> core set debug 6
> core set verbose 6

# add "debug,verbose" to the "console" variable in /etc/asterisk/logger.conf for more logging


